package com.jnu.hc.jnuhcusercms.service;

import com.jnu.hc.jnuhcusercms.domain.Orders;
import com.jnu.hc.jnuhcusercms.dto.CalendarRequestDto;
import com.jnu.hc.jnuhcusercms.dto.ResponseObject;
import com.jnu.hc.jnuhcusercms.mapper.OrdersMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
@Service
public class OrdersServiceImpl implements OrdersService {
    @Autowired
    OrdersMapper ordersMapper;
    @Override
    public ResponseObject countOrder(Orders orders){
        int duplicateCount=ordersMapper.countOrder(orders.getHpId(),orders.getSmId());
        if(duplicateCount>0){
            System.out.println(duplicateCount);
            return new ResponseObject(409,"已存在相同医院和套餐的预约记录！");
        }
        System.out.println(duplicateCount);
        return new ResponseObject(ResponseObject.SUCCESS_STATUS,ResponseObject.SUCCESS_DESC);

    }
    @Override
    public ResponseObject saveOrders(Orders orders){
        ordersMapper.insert(orders);
        return new ResponseObject(ResponseObject.SUCCESS_STATUS,ResponseObject.SUCCESS_DESC);
    }
}
